package com.easyOrder.service.material;

import com.easyOrder.dao.MaterialClassMapper;
import com.easyOrder.model.MaterialClass;
import com.easyOrder.model.MaterialClassExample;
import com.easyOrder.service.enums.MaterialClassState;
import com.google.common.collect.Lists;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by liutao on 2017/7/17.
 */
@Service
public class MaterialClassService {

    @Autowired
    private MaterialClassMapper materialClassMapper;

    public List<MaterialClass> findValidClassByBranchId(Long branchId){
        MaterialClassExample example = new MaterialClassExample();
        example.createCriteria().andBranchIdEqualTo(branchId).andStatusIdEqualTo(MaterialClassState.normal.getValue());
        List<MaterialClass> materialClasses = materialClassMapper.selectByExample(example);
        if(CollectionUtils.isNotEmpty(materialClasses)){
            return materialClasses;
        }
        return Lists.newArrayList();
    }

}
